//
//  THCalendar.m
//  THCalendar
//
//  Created by 魏鑫 on 2020/12/31.
//

#import "THCalendar.h"
#import "UIColor+FSHex.h"

@implementation THCalendar

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupProperty];
        [self setupAppearance];
    }
    return self;
}

- (void)setupProperty
{
    _lunarFormatter = [[FSLunarFormatter alloc] init];
}

- (void)setupAppearance
{
    self.locale = [NSLocale localeWithLocaleIdentifier:@"zh-CN"];
    
    self.headerHeight = 42;
    self.weekdayHeight = 40;
    self.rowHeight = 40;
    self.appearance.yearmonthTitleAlignment = NSTextAlignmentCenter;
    
    self.appearance.caseOptions = FSCalendarCaseOptionsHeaderUsesUpperCase|FSCalendarCaseOptionsWeekdayUsesSingleUpperCase;
    self.appearance.yearmonthFont = [UIFont systemFontOfSize:18 weight:UIFontWeightMedium];
    self.appearance.weekdayFont = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
    self.appearance.titleFont = [UIFont systemFontOfSize:16 weight:UIFontWeightMedium];
    self.appearance.subtitleFont = [UIFont systemFontOfSize:10 weight:UIFontWeightRegular];
    
    // 白色效果
    if (self.theme == FSCalendarThemeWhite) {
        // 今日背景
        self.appearance.todayColor = [UIColor colorWithHex:@"#FFFFFF"];
        //今日文字
        self.appearance.titleTodayColor = [UIColor colorWithHex:@"#2F69F8"];
        //今日农历文字
        self.appearance.subtitleTodayColor = [UIColor colorWithHex:@"#2F69F8"];
        //年月文字
        self.appearance.yearmonthTextColor = [UIColor colorWithHex:@"#333333"];
        //星期文字
        self.appearance.weekdayTextColor = [UIColor colorWithHex:@"#666666"];
        //事件默认
        self.appearance.eventDefaultColor = [UIColor colorWithHex:@"#2F69F8"];
        //日期默认
        self.appearance.titleDefaultColor = [UIColor colorWithHex:@"#333333"];
        //农历默认
        self.appearance.subtitleDefaultColor = [UIColor colorWithHex:@"#999999"];
        //选中背景填充
        self.appearance.selectionColor = [UIColor colorWithHex:@"#2F69F8"];
    } else {
        // 黑色效果
        self.backgroundColor = [UIColor colorWithHex:@"#0F1E37"];
        // 今日背景
        self.appearance.todayColor = [UIColor colorWithHex:@"#FC792C"];
        //今日文字
        self.appearance.titleTodayColor = [UIColor colorWithHex:@"#FC792C"];
        //今日农历文字
        self.appearance.subtitleTodayColor = [UIColor colorWithHex:@"#FC792C"];
        //年月文字
        self.appearance.yearmonthTextColor = [UIColor colorWithHex:@"#FFFFFF"];
        //星期文字
        self.appearance.weekdayTextColor = [UIColor colorWithRed:255/255. green:255/255. blue:255/255. alpha:0.3];
        //事件默认
        self.appearance.eventDefaultColor = [UIColor colorWithHex:@"#2F69F8"];
        //日期默认
        self.appearance.titleDefaultColor = [UIColor colorWithHex:@"#FFFFFF"];
        //农历默认
        self.appearance.subtitleDefaultColor = [UIColor colorWithHex:@"#999999"];
        //选中背景填充
        self.appearance.selectionColor = [UIColor colorWithHex:@"#2F69F8"];
    }
}


@end
